package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.OrderSettingListDao;
import com.itheima.entity.PageResult;
import com.itheima.pojo.Member;
import com.itheima.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service(interfaceClass = OrderSettingListService.class)
@Transactional
public class OrderSettingListServiceImpl implements OrderSettingListService {

    @Autowired
    private OrderSettingListDao orderSettingListDao;


    @Override
    public PageResult findPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage, pageSize);
        List<Map<String, Object>> pages = orderSettingListDao.selectByCondition(queryString);
        PageInfo<Map<String, Object>> info = new PageInfo<>(pages);
        return new PageResult(info.getTotal(), pages);
    }

    @Override
    public void add(Member member, Order order) {
        orderSettingListDao.addMember(member);
        orderSettingListDao.addOrder(order);
    }

}

